package com.ponhu.ea2.dto;

import com.ponhu.ea2.annotations.EnableColumnChangeLog;
import com.ponhu.ea2.annotations.OperationRecordId;
import com.ponhu.ea2.constants.CommonConstant;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;

@Data
@Accessors(chain = true)
@ApiModel(value = "货品相关商品编辑-数据传输模型 ")
public class PhInventoryGoodsEditDto extends OperatorDto {

    private static final long serialVersionUID = 1L;

    @OperationRecordId(businessTable = CommonConstant.BUSINESS_TYPE_INVENTORY)
    @NotNull(message = "货品ID不可为空")
    @ApiModelProperty(value = "货品ID", required = true)
    private Long inventoryId;

    @ApiModelProperty(value = "货品编码", hidden = true)
    private String inventoryCode;

    @NotNull(message = "商品ID不可为空")
    @ApiModelProperty(value = "商品ID", required = true)
    private Long goodsId;

    @NotEmpty(message = "商品名称不可为空")
    @ApiModelProperty(value = "商品名称")
    private String goodsName;

    @ApiModelProperty(value = "商品卖点")
    @EnableColumnChangeLog(columnDesc = "商品卖点")
    private String sellingPoint;

    @ApiModelProperty(value = "货品备注")
    @EnableColumnChangeLog(columnDesc = "货品备注")
    private String remarks;

    @NotNull(message = "货品成本不可为空")
    @ApiModelProperty(value = "货品成本")
    @EnableColumnChangeLog(columnDesc = "成本价")
    private BigDecimal inventoryCost;

    @NotNull(message = "入库价不可为空")
    @ApiModelProperty(value = "入库价")
    @EnableColumnChangeLog(columnDesc = "入库价")
    private BigDecimal warehousePrice;

    @NotNull(message = "含税销售价不可为空")
    @ApiModelProperty(value = "含税销售价")
    @EnableColumnChangeLog(columnDesc = "含税销售价")
    private BigDecimal saleTaxPrice;

    @NotNull(message = "含税供货价不可为空")
    @ApiModelProperty(value = "含税供货价")
    @EnableColumnChangeLog(columnDesc = "含税供货价")
    private BigDecimal supplyTaxPrice;

    public String getGoodsName() {
        if (StringUtils.isEmpty(goodsName))
            return goodsName;
        return goodsName.trim();
    }

    public void setGoodsName(String goodsName) {
        if (StringUtils.isNotEmpty(goodsName))
            goodsName = goodsName.trim();
        this.goodsName = goodsName;
    }

    public String getSellingPoint() {
        if (StringUtils.isEmpty(sellingPoint))
            return sellingPoint;
        return sellingPoint.trim();
    }

    public void setSellingPoint(String sellingPoint) {
        if (StringUtils.isNotEmpty(sellingPoint))
            sellingPoint = sellingPoint.trim();
        this.sellingPoint = sellingPoint;
    }

}
